#!/usr/bin/env python

import os, sys
from course_class import Course

def get_settings ( liwe ):
	m =  Course ( liwe )
	resp =  m.get_settings ()
	return { 'setting' : resp }

#{{{def set_course ( liwe, id_course = 0, name = '', descr = '', city = '', address = '', note ='', day_duration = 0, places = 0, visible = 0, tags = '' ):
def set_course ( liwe, id_course = 0, name = '',product_code = '', descr = '', city = '', address = '', note ='', day_duration = 0,
		 places = 0, visible = 0, tags = '', url = '', new_page = 0, desc_breve = '' ):
        """     
        :INPUT:         
                - id_course:		SAFE_NUMBER       
                - name:			SAFE_DB_STRING	
                - product_code:		SAFE_DB_STRING	
                - city:			SAFE_DB_STRING	
                - address:		SAFE_DB_STRING	
                - note:			SAFE_HTML	
                - descr:		SAFE_HTML	
                - day_duration:	SAFE_NUMBER	
                - places:		SAFE_NUMBER	
                - visible:		SAFE_NUMBER	
                - tags:			SAFE_DB_STRING
                - url:			SAFE_DB_STRING  
                - new_page:		SAFE_NUMBER 	
                - desc_breve:	SAFE_HTML	
        :PERMS:                 
                - admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.set_course ( id_course = id_course, name = name, product_code = product_code, descr = descr,
			  city = city, address = address, note = note, day_duration = day_duration, places = places,
			  visible = visible, tags = tags, url = url, new_page = new_page, desc_breve = desc_breve )

	return { 'course' : resp }

#}}}
def set_course_visible ( liwe, id_course = 0, visible = 1 ):
	"""
	:INPUT:
		-id_course: SAFE_NUMBER
		-visible:	SAFE_NUMBER
	:PERMS:                 
			- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	n.set_course_visible ( id_course = id_course, visible = visible )

#{{{def del_course ( liwe, uids = "" ):
def del_course ( liwe, ids = "" ):
	"""
	:INPUT:
		-ids: SAFE_DB_STRING
	:PERMS:
		- delete With this permission you can delete course
	"""
	n = Course ( liwe )
	resp =  n.del_course ( ids =  ids ) 
	
#}}}
#{{{def set_charge ( liwe, id_charge = 0, id_course = 0, descr = '', day_before = 0, value = 0, tax_code = 0 ):
def set_charge ( liwe, id_charge = 0, id_course = 0, product_coupon = '', descr = '', day_before = 0, value = 0, tax_code = 0 ):
        """     
        :INPUT:         
                - id_charge:		SAFE_NUMBER       
                - id_course:		SAFE_NUMBER       
                - product_coupon:	SAFE_DB_STRING       
                - descr:		SAFE_HTML	
                - day_before:		SAFE_NUMBER	
                - value:		SAFE_MONEY	
                - tax_code:		SAFE_NUMBER	
        :PERMS:                 
                - create:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.set_charge ( id_charge = id_charge, id_course = id_course, product_coupon = product_coupon, descr = descr, day_before = day_before, value = value, tax_code = tax_code )
	return { 'charge' : resp }

#}}}
#{{{def del_charge ( liwe, uids = "" ):
def del_charge ( liwe, ids = "" ):
	"""
	:INPUT:
		-ids: SAFE_DB_STRING
	:PERMS:
		- delete With this permission you can delete charge
	"""
	n = Course ( liwe )
	resp =  n.del_charge ( ids =  ids ) 
	
#}}}
#{{{def set_calendar ( liwe, id_calendar = 0, id_course = 0, uid_trainer = 0, city = '', address = '', start_date = '', descr = '' ):
def set_calendar ( liwe, id_calendar = 0, id_course = 0, uid_trainer = 0, city = '', address = '', start_date = '', descr = '' ):
        """     
        :INPUT:         
                - id_calendar:	SAFE_NUMBER       
                - id_course:	SAFE_NUMBER       
                - uid_trainer:	SAFE_NUMBER       
                - start_date:	SAFE_DATE	
                - descr:	SAFE_HTML	
                - city:		SAFE_DB_STRING	
                - address:	SAFE_HTML	
        :PERMS:                 
                - create:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.set_calendar ( id_calendar = id_calendar, id_course = id_course, uid_trainer = uid_trainer, city = city, address = address, start_date = start_date, descr = descr );
	return { 'calendar' : resp }

#}}}
#{{{def del_calendar ( liwe, uids = "" ):
def del_calendar ( liwe, ids = "" ):
	"""
	:INPUT:
		-ids: SAFE_DB_STRING
	:PERMS:
		- delete With this permission you can delete course
	"""
	n = Course ( liwe )
	resp =  n.del_calendar ( ids =  ids ) 
	
#}}}

#{{{def set_user ( liwe,id_user = 0, uid = 0, id_calendar = 0, id_course = 0, subscription_date = '', pay = 0, paid = 0, note = '', description = '' ):
def set_user ( liwe,id_user = 0, uid = 0, id_calendar = 0, id_course = 0, subscription_date = '', pay = 0, paid = 0, note = '', send_mail = '', transaction_kind = '' ):
        """     
        :INPUT:        	 
        - id_user:		SAFE_NUMBER       
        - uid:			SAFE_NUMBER       
        - id_calendar:		SAFE_NUMBER       
        - id_course:		SAFE_NUMBER       
        - subscription_date:	SAFE_DATE	
        - pay:			SAFE_MONEY	
	- paid:			SAFE_MONEY	
        - note:			SAFE_DB_STRING
	- send_mail:		SAFE_DB_STRING
	- transaction_kind:	SAFE_DB_STRING

	:PERMS:                 
	- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )



	resp = n.set_user ( id_user = id_user, uid = uid, id_calendar = id_calendar,
			    id_course = id_course, subscription_date = subscription_date,
			    pay = pay, paid = paid, note = note, send_mail = send_mail, transaction_kind = transaction_kind )

	return { 'user' : resp }

#}}}
#{{{def del_user ( liwe, uids = "" ):
def del_user ( liwe, ids = "" ):
	"""
	:INPUT:
		-ids: SAFE_DB_STRING
	:PERMS:
		- delete With this permission you can delete course
	"""
	n = Course ( liwe )
	resp =  n.del_user ( ids =  ids ) 
	
#}}}
def list_teacher ( liwe ):
	"""
	:INPUT:
	:PERMS:                 
			- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.list_teacher()
	return { 'teachers' : resp }

def list_student ( liwe ):
	"""
	:INPUT:
	:PERMS:                 
			- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.list_student()
	return { 'students' : resp }

def list_all ( liwe ):
	"""
	:INPUT:
	:PERMS:                 
			- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.list_all()
	return  resp 

def distinct_date_user ( liwe, id_course = 0 ):
	"""
	:INPUT:
		-id_course: SAFE_NUMBER
	:PERMS:                 
			- admin:	With this permission you can create/modify
	"""
	n = Course ( liwe )
	resp = n.distinct_date_user ( id_course = id_course )
	return { 'dates' : resp }

